home *** CD-ROM | disk | FTP | other *** search
/ Netware Super Library / Netware Super Library.iso / drivers / nics / pktdrv7 / nti16.asm < prev    next >
Encoding:
Assembly Source File  |  1990-07-27  |  45.0 KB  |  1,705 lines

  1. version    equ    0
  2.  
  3.     include    defs.asm
  4. ;        ntinet.mac
  5. ;
  6. ;  macros used for calling c routines.
  7. ;
  8. pusharg    macro    seg, off
  9.     ifnb    <seg>
  10.       push    seg
  11.     $$cnt = $$cnt+2
  12.     endif
  13.     ifnb    <off>
  14.       push    off
  15.     $$cnt = $$cnt+2
  16.     endif
  17.     endm
  18.  
  19.  
  20. ccall    macro    rtn, p1, p2, p3, p4, p5
  21. $$cnt = 0
  22.     ifnb    <p5>
  23.       pusharg    p5
  24.     endif
  25.     ifnb    <p4>
  26.       pusharg    p4
  27.     endif
  28.     ifnb    <p3>
  29.       pusharg    p3
  30.     endif
  31.     ifnb    <p2>
  32.       pusharg    p2
  33.     endif
  34.     ifnb    <p1>
  35.       pusharg    p1
  36.     endif
  37.       call    rtn
  38.     if $$cnt
  39.       add    sp,$$cnt
  40.     endif
  41.     endm
  42.  
  43. save    macro    regs
  44.       irp    arg,<regs>
  45.       push    arg
  46.       endm
  47.     endm
  48.     
  49. restore    macro    regs
  50.       irp    arg,<regs>
  51.       pop    arg
  52.       endm
  53.     endm    
  54.  
  55. ;
  56. ; LANCE.INC
  57. ;
  58. ; lance registers
  59. ;
  60. CSR0    equ    0        ;control and status register 0
  61. CSR1    equ    1
  62. CSR2    equ    2
  63. CSR3    equ    3
  64. ;
  65. ;-------------------------------------------------------------------------
  66. ; control and status register 0
  67. ; rap = 0
  68. ;
  69. ;    |---------------|---------------|---------------|---------------|
  70. ;    |15 |14 |13 |12 |11 |10 | 9 | 8 | 7 | 6    | 5 | 4 | 3 | 2 | 1 | 0    |
  71. ;    |---------------------------------------------------------------|
  72. ;    | e | b | c | m    | m | r    | t | i    | i | i | r | t    | t | s    | s | i    |
  73. ;    | r | a    | e | i    | e | i    | i | d    | n | n | x | x    | d | t    | t | n    |
  74. ;    | r | b    | r | s    | r | n    | n | o    | t | e | o | o    | n | o    | r | i    |
  75. ;    |   | l    | r | s    | r | t    | t | n    | r | a | n | n    | d | p    | t | t    |
  76. ;    |---------------|---------------|---------------|---------------|
  77. ;
  78. L_ERR    equ    8000h        ;or of babl, cerr, miss, merr (read only)
  79. L_BABL    equ    4000h        ;transmit timeout error    (write 1 clear)
  80. L_CERR    equ    2000h        ;collision error (sqe error) (write 1 clear)
  81. L_MISS    equ    1000h        ;no buffer on receive (write 1 clear)
  82. ;
  83. L_MERR    equ    0800h        ;bus timeout error (write 1 clear)
  84. L_RINT    equ    0400h        ;receive interrupt (write 1 clear)
  85. L_TINT    equ    0200h        ;transmit interrupt (write 1 clear)
  86. L_IDON    equ    0100h        ;initialization done (write 1 clear)
  87. ;
  88. L_INTR    equ    0080h    ;interrupt (or of babl,miss,merr,rint,tint,idon
  89. L_INEA    equ    0040h        ;interrupt enable
  90. L_RXON    equ    0020h        ;receiver on
  91. L_TXON    equ    0010h        ;transmitter on
  92. ;
  93. L_TDND    equ    0008h        ;transmit demand
  94. L_STOP    equ    0004h        ;stop
  95. L_STRT    equ    0002h        ;start
  96. L_INIT    equ    0001h        ;initialize
  97. ;
  98. L_MASK    equ    l_babl+l_cerr+l_miss+l_merr+l_rint+l_tint
  99.  
  100.  
  101.  
  102. ;-----------------------------------------------------------------------
  103. ; control and status register 1
  104. ; rap = 1
  105. ;
  106. ;  Accessable when csr0 stop = 1
  107. ;
  108. ;     ---------------------------------------------------------------
  109. ;    |15 |14 |13 |12 |11 |10 | 9 | 8 | 7 | 6    | 5 | 4 | 3 | 2 | 1 | 0    |
  110. ;    |---------------------------------------------------------------|
  111. ;    |                  iadr  (bits 1 - 15)                      | 0 |
  112. ;     ---------------------------------------------------------------
  113. ;
  114. ; iadr - The low order 16 bits of the address of the first
  115. ;         in the initialization Block.
  116. ;
  117. ;----------------------------------------------------------------------
  118. ; control and status register 2
  119. ; rap = 2
  120. ;
  121. ;  Accessable when csr0 stop = 1
  122. ;
  123. ;    |---------------|---------------|---------------|---------------|
  124. ;    |15 |14 |13 |12 |11 |10 | 9 | 8 | 7 | 6    | 5 | 4 | 3 | 2 | 1 | 0    |
  125. ;    |---------------------------------------------------------------|
  126. ;    | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |       iadr (bits 16 - 32)     |
  127. ;     ---------------------------------------------------------------
  128. ;
  129. ; iadr - (bits 16 - 32) The hi order 8 bits of the address of the first
  130. ;         in the initialization Block.
  131. ;
  132. ;-------------------------------------------------------------------------
  133. ; control and status register 3
  134. ; rap = 3
  135. ;
  136. ;  Accessable when csr0 stop = 1
  137. ;
  138. ;    |---------------|---------------|---------------|---------------|
  139. ;    |15 |14 |13 |12 |11 |10 | 9 | 8 | 7 | 6    | 5 | 4 | 3 | 2 | 1 | 0    |
  140. ;    |---------------------------------------------------------------|
  141. ;    | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | b    | a | b    |
  142. ;       |                                                   | s    | c | c    |
  143. ;    |                                                   | w    | o | o    |
  144. ;       |                                                   | p    | n | n    |
  145. ;     ---------------------------------------------------------------
  146. ;
  147. L_BSWP    equ    0004            ;0 = <0:7> even addresses byte swap 
  148. L_ACON    equ    0002            ;0 = ale, 1 = /as
  149. L_BCON    equ    0001            ;0 = /bm1, bm0, /hold
  150. ;
  151. BUS_MASTER    equ    0        ;initialization word
  152. ;
  153.  
  154.  
  155.  
  156. ;------------------------------------------------------------------------
  157. ; initialization block
  158. ;
  159. init_block    struc
  160. i_mode    dw    0        ;mode register usually 0
  161. i_padr    db    0,0,0,0,0,0    ;ethernet address
  162. i_ladrf    db    0,0,0,0,0,0,0,0    ;logical address filter (mulitcast filter)
  163. i_rdra    dw    0        ;lo order pointer to receive descriptor ring
  164. i_rlen    dw    0        ;number of rec descriptors (power of 2)
  165. i_tdra    dw    0        ;lo order pointer to transmit descriptor ring
  166. i_tlen    dw    0        ;number of xmit descritport (power of 2)
  167. init_block    ends
  168.  
  169. INITBLK_SZ    equ    SIZE     init_block
  170.  
  171. ;
  172. ;l_mode
  173. ;
  174. ; offset
  175. ;    |---------------|---------------|---------------|---------------|
  176. ;   00    |15 |14 |13 |12 |11 |10 | 9 | 8 | 7 | 6    | 5 | 4 | 3 | 2 | 1 | 0    |
  177. ;    |---------------------------------------------------------------|
  178. ;    | p | 0    | 0 | 0    | 0 | 0    | 0 | 0    | 0 | i | d | c | d | l    | d | d    |
  179. ;    | r |                     | n | t | o | t | o    | t | r    |
  180. ;    | o |                     | t | r | l | c | o    | x | x    |
  181. ;    | m |                     | l | y | l | r | p    |   |    |
  182. ;     ---------------------------------------------------------------
  183. ;
  184. L_PROM    equ    8000h        ;promiscuous mode
  185. L_INTL    equ    0040h        ;internal loop back
  186. L_DRTY    equ    0020h        ;disable retry
  187. L_COLL    equ    0010h        ;force collision
  188. L_DTCR    equ    0008h        ;disable transmit crc
  189. L_LOOP    equ    00040        ;loop back
  190. L_DTX    equ    0002h        ;disable transmitter
  191. L_DRX    equ    0001h        ;disable receiver
  192. ;
  193. RUN_MODE    equ    0        ;run mode
  194. XMIT_MODE    equ    l_drx        ;disable receiver
  195. RCV_MODE    equ    l_dtx        ;disable xmitter
  196. TEST_MODE    equ    l_intl+l_loop    ;diagnostics mode
  197. ;
  198.  
  199.  
  200.  
  201. ; physical address
  202. ;
  203. ; offset
  204. ;     ---------------------------------------------------------------
  205. ;   02    |15 |14 |13 |12 |11 |10 | 9 | 8 | 7 | 6    | 5 | 4 | 3 | 2 | 1 | 0    |
  206. ;    |---------------------------------------------------------------|
  207. ;    |                       bits 0 - 15                         | 0 |
  208. ;     ---------------------------------------------------------------
  209. ;
  210. ;     ---------------------------------------------------------------
  211. ;   04    |15 |14 |13 |12 |11 |10 | 9 | 8 | 7 | 6    | 5 | 4 | 3 | 2 | 1 | 0    |
  212. ;    |---------------------------------------------------------------|
  213. ;    |                       bits 16 - 31                            |
  214. ;     ---------------------------------------------------------------
  215. ;
  216. ;     ---------------------------------------------------------------
  217. ;   06    |15 |14 |13 |12 |11 |10 | 9 | 8 | 7 | 6    | 5 | 4 | 3 | 2 | 1 | 0    |
  218. ;    |---------------------------------------------------------------|
  219. ;    |                       bits 32 - 47                    |
  220. ;     ---------------------------------------------------------------
  221. ;
  222. ;
  223. ; Multicast address
  224. ;
  225. ; offset
  226. ;     ---------------------------------------------------------------
  227. ;   08    |15 |14 |13 |12 |11 |10 | 9 | 8 | 7 | 6    | 5 | 4 | 3 | 2 | 1 | 0    |
  228. ;    |---------------------------------------------------------------|
  229. ;    |                       bits 0 - 15                             |
  230. ;     ---------------------------------------------------------------
  231. ;
  232. ;     ---------------------------------------------------------------
  233. ;   0a    |15 |14 |13 |12 |11 |10 | 9 | 8 | 7 | 6    | 5 | 4 | 3 | 2 | 1 | 0    |
  234. ;    |---------------------------------------------------------------|
  235. ;    |                       bits 16 - 31                            |
  236. ;     ---------------------------------------------------------------
  237. ;
  238. ;     ---------------------------------------------------------------
  239. ;   0c    |15 |14 |13 |12 |11 |10 | 9 | 8 | 7 | 6    | 5 | 4 | 3 | 2 | 1 | 0    |
  240. ;    |---------------------------------------------------------------|
  241. ;    |                       bits 32 - 47                    |
  242. ;     ---------------------------------------------------------------
  243. ;
  244. ;     ---------------------------------------------------------------
  245. ;   0e  |15 |14 |13 |12 |11 |10 | 9 | 8 | 7 | 6    | 5 | 4 | 3 | 2 | 1 | 0    |
  246. ;    |---------------------------------------------------------------|
  247. ;    |                       bits 38 - 63                    |
  248. ;     ---------------------------------------------------------------
  249. ;
  250. ;
  251. ; Receive Descriptor Ring Pointer
  252. ;
  253. ; offset
  254. ;    |---------------|---------------|---------------|---------------|
  255. ;   10    |15 |14 |13 |12 |11 |10 | 9 | 8 | 7 | 6    | 5 | 4 | 3 | 2 | 1 | 0    |
  256. ;    |---------------------------------------------------------------|
  257. ;    |   rlen    | 0 | 0 | 0 | 0 | 0 |     rdra  (bits 16 - 23)      |
  258. ;     ---------------------------------------------------------------
  259. ;
  260. ;    |---------------|---------------|---------------|---------------|
  261. ;   12    |15 |14 |13 |12 |11 |10 | 9 | 8 | 7 | 6    | 5 | 4 | 3 | 2 | 1 | 0    |
  262. ;    |---------------------------------------------------------------|
  263. ;    |                       rdra  (bits 3 - 15)        | 0 | 0 | 0 |
  264. ;     ---------------------------------------------------------------
  265. ;     note rings are aligned on quad word boundries
  266. ;
  267. ;                number of entries
  268. ;                    -----------------
  269. RLEN1    equ    00h    ; 1
  270. RLEN2    equ    20h      ; 2
  271. RLEN4    equ    40h      ; 4
  272. RLEN8    equ    60h      ; 8
  273. RLEN16    equ    80h     ; 16
  274. RLEN32    equ    0a0h     ; 32
  275. RLEN64    equ    0c0h     ; 64
  276. RLEN128    equ    0e0h    ; 128
  277. ;
  278. ; Transmit Descriptor Ring Pointer
  279. ;
  280. ; offset
  281. ;    |---------------|---------------|---------------|---------------|
  282. ;   14    |15 |14 |13 |12 |11 |10 | 9 | 8 | 7 | 6    | 5 | 4 | 3 | 2 | 1 | 0    |
  283. ;    |---------------------------------------------------------------|
  284. ;    |   tlen    | 0 | 0 | 0 | 0 | 0 |     tdra  (bits 16 - 23)      |
  285. ;     ---------------------------------------------------------------
  286. ;
  287. ;    |---------------|---------------|---------------|---------------|
  288. ;   16    |15 |14 |13 |12 |11 |10 | 9 | 8 | 7 | 6    | 5 | 4 | 3 | 2 | 1 | 0    |
  289. ;    |---------------------------------------------------------------|
  290. ;    |                       tdra  (bits 3 - 15)        | 0 | 0 | 0 |
  291. ;     ---------------------------------------------------------------
  292. ;     note rings are aligned on quad word boundries
  293. ;
  294. ;             number of entries
  295. ;                -----------------
  296. TLEN1    equ    00h    ; 1
  297. TLEN2    equ    20h      ; 2
  298. TLEN4    equ    40h      ; 4
  299. TLEN8    equ    60h      ; 8
  300. TLEN16    equ    80h     ; 16
  301. TLEN32    equ    0a0h     ; 32
  302. TLEN64    equ    0c0h     ; 64
  303. TLEN128    equ    0e0h    ; 128
  304. ;
  305. ;------------------------------------------------------------------------
  306. ;
  307. ; Receive descriptor ring
  308. ;
  309. rec_desc_ring    struc
  310. rd_addr    dw    0        ;lo order address of the buffer attached
  311. rd_stat    dw    0        ;buffer status and hi order pointer
  312. rd_bcnt    dw    0        ;buffer byte count
  313. rd_mcnt    dw    0        ;message byte count
  314. rec_desc_ring    ends
  315. RDESCLEN    equ    SIZE rec_desc_ring
  316. ;
  317. ;
  318. ; rmd0
  319. ; rd_addr
  320. ;
  321. ;offset     ---------------------------------------------------------------
  322. ;   00    |15 |14 |13 |12 |11 |10 | 9 | 8 | 7 | 6    | 5 | 4 | 3 | 2 | 1 | 0    |
  323. ;    |---------------------------------------------------------------|
  324. ;    |                     ladr  (bits 0 - 15)                       |
  325. ;     ---------------------------------------------------------------
  326. ;
  327. ; lo order 16 bits of the buffer pointed to by this descriptor
  328. ;
  329. ;
  330. ; rmd1
  331. ; rd_stat
  332. ;
  333. ;    |---------------|---------------|---------------|---------------|
  334. ;   02    |15 |14 |13 |12 |11 |10 | 9 | 8 | 7 | 6    | 5 | 4 | 3 | 2 | 1 | 0    |
  335. ;    |---------------------------------------------------------------|
  336. ;    | o | e | f | o    | c | b    | s | e    |     hadr  (bits 16 - 23)      |
  337. ;    | w | r    | r | f    | r | u    | t | n    |                 |
  338. ;    | n | r    | a | l    | c | f    | p | p    |                 |
  339. ;    |   |     | m | o    |   | f    |   |     |                 |
  340. ;     ---------------------------------------------------------------
  341. ;
  342. ; status and hi order bits of buffer pointer to by this descriptor
  343. ;
  344. R_OWN    equ    8000h        ;0 = full, host set after read data
  345. R_ERR    equ    4000h
  346. ;
  347. ; receive status
  348. R_FRAM    equ    2000h        ;framing error (cleared by host)
  349. R_OFLO    equ    1000h        ;silo overflow (cleared by host)
  350. R_CRC    equ    0800h        ;crc error (cleared by host)
  351. R_BUFF    equ    0400h        ;buffer error (cleared by host)
  352. R_STP    equ    0200h        ;Start of Packet (cleared by host)
  353. R_ENP    equ    0100h        ;End of Packet (cleared by host)
  354. ;
  355. ; rmd2
  356. ; rd_bcnt
  357. ;
  358. ;    |---------------|---------------|---------------|---------------|
  359. ;   04    |15 |14 |13 |12 |11 |10 | 9 | 8 | 7 | 6    | 5 | 4 | 3 | 2 | 1 | 0    |
  360. ;    |---------------------------------------------------------------|
  361. ;    | 1 | 1 | 1 | 1    |               bcnt                            |
  362. ;     ---------------------------------------------------------------
  363. ;
  364. ; bcnt - Length of buffer pointed to by this desctriptor, two's compliment
  365. ;
  366. RD_MASK    equ    0F000h        ;or mask
  367. ;
  368. ; rmd3
  369. ; rd_mcnt
  370. ;
  371. ;    |---------------|---------------|---------------|---------------|
  372. ;   06    |15 |14 |13 |12 |11 |10 | 9 | 8 | 7 | 6    | 5 | 4 | 3 | 2 | 1 | 0    |
  373. ;    |---------------------------------------------------------------|
  374. ;    | 0 | 0 | 0 | 0    |               mcnt                            |
  375. ;     ---------------------------------------------------------------
  376. ;
  377. ; mcnt - Length of message in buffer
  378. ;
  379. mcnt_mask    equ    0fffh    ;
  380.  
  381. ;------------------------------------------------------------------------
  382. ;
  383. ; Transmit descriptor ring
  384. ;
  385. xmt_desc_ring    struc
  386. td_addr    dw    0        ;lo order address of the buffer attached
  387. td_stat    dw    0        ;buffer status and hi order pointer
  388. td_bcnt    dw    0        ;buffer byte count
  389. td_tdr    dw    0        ;errors and tdr count
  390. xmt_desc_ring    ends
  391. TDESCLEN    equ    SIZE xmt_desc_ring
  392. ;
  393. ;
  394. ; tmd0
  395. ; td_addr
  396. ;    |---------------|---------------|---------------|---------------|
  397. ;   00    |15 |14 |13 |12 |11 |10 | 9 | 8 | 7 | 6    | 5 | 4 | 3 | 2 | 1 | 0    |
  398. ;    |---------------------------------------------------------------|
  399. ;    |                     ladr  (bits 0 - 15)                       |
  400. ;     ---------------------------------------------------------------
  401. ;
  402. ; lo order 16 bits of the buffer pointed to by this descriptor
  403. ;
  404. ;
  405. ; tmd1
  406. ; td_stat
  407. ;
  408. ;    |---------------|---------------|---------------|---------------|
  409. ;   02    |15 |14 |13 |12 |11 |10 | 9 | 8 | 7 | 6    | 5 | 4 | 3 | 2 | 1 | 0    |
  410. ;    |---------------------------------------------------------------|
  411. ;    | o | e | 0 | m    | o | d    | s | e    |     hadr  (bits 16 - 23)      |
  412. ;    | w | r    |   | o    | n | e    | t | n    |                 |
  413. ;    | n | r    |   | r    | e | f    | p | p    |                 |
  414. ;    |   |     |   | e    |   |     |   |     |                 |
  415. ;     ---------------------------------------------------------------
  416. ;
  417. ; status and hi order bits of buffer pointer to by this descriptor
  418. ;
  419. ;
  420. ; transmit status
  421. ;
  422. T_OWN    equ    8000h        ;0 = empty host set when full
  423. T_ERR    equ    4000h
  424. ;
  425. T_MORE    equ    1000h        ;16 retrys (set by lance, cleared by host)
  426. T_ONE    equ    0800h        ;one retry (set by lance, cleared by host)
  427. T_DEF    equ    0400h        ;deffered xsmit (setby lance, cleared by host)
  428. T_STP    equ    0200h        ;First buffer in packet (set/cleared by host)
  429. T_ENP    equ    0100h        ;End of Packet (set/cleared by host
  430. ;
  431. ;
  432. ;
  433. ; tmd2
  434. ; td_bcnt
  435. ;
  436. ;    |---------------|---------------|---------------|---------------|
  437. ;   04    |15 |14 |13 |12 |11 |10 | 9 | 8 | 7 | 6    | 5 | 4 | 3 | 2 | 1 | 0    |
  438. ;    |---------------------------------------------------------------|
  439. ;    | 1 | 1 | 1 | 1    |               bcnt                            |
  440. ;     ---------------------------------------------------------------
  441. ;
  442. ; bcnt - Length of buffer pointed to by this desctriptor, expressed as a
  443. ;        twos compliment negative number.
  444. ;
  445. TD_BMASK    equ    0F000h        ;or mask
  446. ;
  447. ;
  448. ;
  449. ; tmd3
  450. ; td_tdr
  451. ;
  452. ;    |---------------|---------------|---------------|---------------|
  453. ;   06    |15 |14 |13 |12 |11 |10 | 9 | 8 | 7 | 6    | 5 | 4 | 3 | 2 | 1 | 0    |
  454. ;    |---------------------------------------------------------------|
  455. ;    | b | u | 0 | l    | l | r |   tdr  (time domain reflectometery)   |
  456. ;    | u | f    |   | c    | c | t    |                    |
  457. ;    | f | l    |   | o    | a | r    |                    |
  458. ;    | f | o    |   | l    | r | y    |                    |
  459. ;     ---------------------------------------------------------------
  460. ;    only valid if the err bit in tmd1 is set
  461. ;
  462. T_BUFF    equ    8000h    ;buffer error (set by lance, uflo also set)
  463. T_UFLO    equ    4000h    ;silo underflow (set by lance,cleared by host)
  464. T_LCOL    equ    1000h    ;late collision (set by lance,cleared by host)
  465. T_LCAR    equ    0800h    ;loss of carrier (set by lance,cleared by host)
  466. T_RTRY    equ    0400h    ;tried 16 times (set by lance,cleared by host)
  467.  
  468. ;
  469. ;  GLBL.INC
  470. ;
  471. ;  global equates for lance dumb board
  472. ;
  473. pt_status    equ    0        ;read status port
  474. pt_clrclk    equ    0        ;write to clear clock interrupt
  475. pt_etaddr    equ    1        ;read ether address rom offset
  476. pt_resetl    equ    1        ;write to reset lance
  477. pt_ldata    equ    2        ;lance data port 2,3
  478. pt_laddr    equ    4        ;lance address port 4,5
  479.  
  480. st_mask        equ    0ch        ;00001100B for (is1 is0)
  481.  
  482. ;int selects
  483. irqn_10    equ    00h            ;(is0 is1) = (0 0)
  484. irqn_11    equ    04h            ;(0 1)
  485. irqn_12    equ    08h            ;(1 0)
  486. irqn_15    equ    0ch            ;(1 1)
  487.  
  488. IRQ10        equ    10
  489.  
  490. ; status port bits
  491.  
  492. NET_INT    equ    01h        ;bit for net interrupt status
  493. CLK_INT    equ    02h        ;bit for clock interrupt status
  494. IPL    equ    04h        ;ipl bit
  495. HILO    equ    08h        ;ram at 0000, or ram at 8000
  496. MINT    equ    net_int+clk_int        ;interrupt mask
  497. ADDR    equ    0F0h        ;mask for dual port segment
  498.  
  499.  
  500. DPLEN    equ    8000h        ;length of dual port ram
  501. BUFSIZE equ    1518        ;should change to GIANT + 4(CRC)
  502.  
  503. ; Packet sizes = source(6) + destination(6) + type (2) + I field. (803.2 spec)
  504. ;
  505.  
  506. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  507. ;
  508. ;Following is the list of variables that need to be adjusted if the dp
  509. ;usage is changed:
  510. ;
  511. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  512.  
  513. XAREA        equ    5F78H        ;start of transmit descriptors
  514. RAREA        equ    0018h        ;start of receive descriptors
  515.  
  516. NUMTDESC    equ    4        ;number of transmit descriptors
  517. NUMRDESC    equ    16         ;number of receive descriptors
  518.  
  519. TBAREA    equ    XAREA+(NUMTDESC*tdesclen)    ;xmit buf pool
  520. RBAREA    equ    RAREA+(NUMRDESC*rdesclen)       ;rcv buffer pool
  521.  
  522. ;our data segment is a constant distance from the es!
  523. OUROFFSET    equ    TBAREA + NUMTDESC*BUFSIZE
  524.  
  525. RLEN    equ    RLEN16            ;lance mask for rcv-descriptors
  526. TLEN    equ    TLEN4            ;lance mask for snd-descriptors
  527.  
  528. ;the total dp size reserved for lance use
  529. LANCE_SZ equ    INITBLK_SZ+ NUMRDESC*(RDESCLEN+BUFSIZE)+ NUMTDESC*(TDESCLEN+BUFSIZE)
  530.  
  531. ;the end of RAERA
  532. OUTOF_BOUND    equ     RBAREA        ;98; for wrap up checking of r-descs
  533.  
  534.  
  535. code    segment    word public
  536.     assume    cs:code, ds:code
  537.  
  538.     extrn    maskint:near
  539.     extrn    set_recv_isr: near
  540.  
  541.  
  542.     public    int_no, io_addr, base_addr
  543. int_no        db    3,0,0,0        ; interrupt number. 
  544. io_addr        dw    0338h,0        ; I/O address for card (jumpers)
  545. base_addr    dw      0d000h,0    ; base segment for board (jumper set)
  546.  
  547. int_no_name    db    "Interrupt number ",'$'
  548. io_addr_name    db    "I/O port ",'$'
  549. base_addr_name    db    "Memory address ",'$'
  550.  
  551. nosdesc_msg    db    CR,LF,"no send descriptor.",'$'
  552. chperr_msg    db    CR,LF,"chip doesn't want to finish init",'$'
  553. porterr_msg    db    CR,LF,"wrong port #",'$'
  554. hwerr_msg    db    CR,LF,"hardware error",'$'
  555. initerr_msg    db     CR,LF,"can't init lance chip",'$'
  556. good_msg    db    CR,LF,"Lance initialized successfully.",'$'
  557. reset_msg    db    CR,LF,"Can't reset the interface",'$'
  558. interr_msg    db    CR,LF,"IRQ# parameter wrong.",'$'
  559.  
  560.     public    driver_class, driver_type, driver_name, driver_function, parameter_list
  561. driver_class    db    1        ;from the packet spec
  562. driver_type    db    100        ;--mz?
  563. driver_name    db    'nti',0,'$'    ;name of the driver.
  564. driver_function    db    2
  565. parameter_list    label    byte
  566.     db    1    ;major rev of packet driver
  567.     db    9    ;minor rev of packet driver
  568.     db    14    ;length of parameter list
  569.     db    EADDR_LEN    ;length of MAC-layer address
  570.     dw    GIANT    ;MTU, including MAC headers
  571.     dw    MAX_MULTICAST * EADDR_LEN    ;buffer size of multicast addrs
  572.     dw    0    ;(# of back-to-back MTU rcvs) - 1
  573.     dw    0    ;(# of successive xmits) - 1
  574. int_num    dw    0    ;Interrupt # to hook for post-EOI
  575.             ;processing, 0 == none,
  576.  
  577.     public    rcv_modes
  578. rcv_modes    dw    4        ;number of receive modes in our table.
  579.         dw    0,0,0,rcv_mode_3
  580.  
  581.  
  582.     ;begin importing data
  583.     public    UNITID, sdesc_cnt, rdesc_cnt, actsdesc, actrdesc
  584. UNITID    db    6 dup (0)        ;current ether address of the interface
  585. sdesc_cnt    dw    2        ;
  586. rdesc_cnt    dw    8
  587. actsdesc    dw    0
  588. actrdesc    dw    0
  589.  
  590.  
  591.  
  592. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  593. ; send_pkt:
  594. ;
  595. ;enter with ds:si -> packet, cx = packet length.
  596. ;exit with nc if ok, or else cy if error, dh set to error number.
  597. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  598.  
  599.     public    as_send_pkt
  600. ; The Asynchronous Transmit Packet routine.
  601. ; Enter with es:di -> i/o control block, ds:si -> packet, cx = packet length,
  602. ;   interrupts possibly enabled.
  603. ; Exit with nc if ok, or else cy if error, dh set to error number.
  604. ;   es:di and interrupt enable flag preserved on exit.
  605. as_send_pkt:
  606.     ret
  607.  
  608.     public    drop_pkt
  609. ; Drop a packet from the queue.
  610. ; Enter with es:di -> iocb.
  611. drop_pkt:
  612.     assume    ds:nothing
  613.     ret
  614.  
  615.     public    xmit
  616. ; Process a transmit interrupt with the least possible latency to achieve
  617. ;   back-to-back packet transmissions.
  618. ; May only use ax and dx.
  619. xmit:
  620.     assume    ds:nothing
  621.     ret
  622.  
  623.  
  624.     public    send_pkt
  625. send_pkt:
  626.     assume    ds:nothing
  627.     push    es
  628.     call    set_dp
  629.  
  630.     push    ds
  631.     call    set_ds            ;set out ds-->cs
  632.  
  633.     mov    dx,cx            ;a copy of length
  634.  
  635.     cmp    dx,GIANT        ; Is this packet too large?
  636.     ja    send_pkt_toobig
  637.  
  638.     cmp    dx,RUNT            ; minimum length for Ether
  639.     jnb    oklen
  640.     mov    dx,RUNT            ; make sure size at least RUNT
  641. oklen:
  642.     mov    bx,[actsdesc]        ;get pointer to active snd desc
  643.     mov    cx,0            ;set up count down parameters
  644. td10:
  645.     test    es:td_stat[bx],t_own    ;have empty buffer?
  646.     jz    dox0            ;yes, then send message
  647.     loop    td10            ;otherwise, wait for it
  648.     mov    dx,offset nosdesc_msg
  649.     ccall    _dispMSG,dx
  650.     mov    dh,CANT_SEND
  651.     stc                ;error ret
  652.     pop    ds
  653.     pop    es
  654.     ret
  655.  
  656. dox0:
  657.     pop    ds
  658.     mov    cx,dx            ;get back the real length
  659.     call    fill            ;ds:si - source, es:bx - dest, cx:length
  660.     ;ax has the return code, either 0 or 0ffh
  661.  
  662.     ;is chip functioning?
  663.     cmp    ax,0ffh            ;fatal error happened last time?
  664.     je    td15            ;error!
  665.     clc                ;good ret
  666.     pop es
  667.     ret
  668. td15:
  669.     mov    dh,CANT_SEND
  670.     stc
  671.     pop    es
  672.     ret
  673.  
  674. send_pkt_toobig:
  675.     mov    dh,NO_SPACE
  676.     stc
  677.     pop    ds
  678.     pop    es
  679.     ret
  680.  
  681.  
  682. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  683. ; fill - proc the xerror  & copy message to xmit buffer
  684. ;
  685. ; entry - es:bx points to free xmit descriptor (dest)
  686. ;      ds:si --> source buf pointer
  687. ;        cx:length of data
  688. ;
  689. ; exit  - xmit buffer (bx) filled
  690. ;      ax = 0: OK; 0ffh: fatal error happened last send
  691. ;      bx changed
  692. ;
  693. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  694.     public    fill
  695. fill:
  696.     assume    ds:nothing
  697.     push    ds                ;save theirs
  698.  
  699.     call    set_ds                ;set ours
  700.  
  701.     call    xmt_errs            ;process previous errors
  702.     cmp    ax,0
  703.     je    success
  704.     pop    ds
  705.     ret                    ;ax == ffh
  706.  
  707. success:    
  708.     ;ds:si - source, es:bx - dest, cx - length
  709.     ;simply send whatever given by the application, assuming the
  710.     ;destination address and everything has been taken care of
  711.  
  712.     pop    ds
  713.     push    cx            ;save it
  714.     mov    di,es:td_addr[bx]    ;get dest buf pointer 
  715.     call    movemem            ;ds:si --> es:di
  716.     pop    cx
  717.     
  718.     push    ds
  719.     call    set_ds
  720.     ;get the sdesc ready and pump the data out
  721.     neg    cx            ;two's compliment
  722.     or    cx,td_bmask        ;set these bits
  723.     mov    es:td_bcnt[bx],cx    ;set in length to descriptor
  724.     mov    ax,0            ;set descriptor status for lance
  725.     or    ax,t_own        ;he now owns it
  726.     or    ax,t_stp        ;start of packet
  727.     or    ax,t_enp        ;end of packet
  728.     mov    es:td_stat[bx],ax    ;give it away        
  729.     mov    ax,l_tdnd+l_inea    ;tell lance we have data
  730.     call    w_csr                ;send it
  731.  
  732.     ;all done, update the actsdesc
  733.     add    bx,tdesclen        ;point at next descriptor
  734.     dec    word ptr[sdesc_cnt]        ;dec counter
  735.     jnz    tfl                ;used all?
  736.     mov    word ptr[sdesc_cnt],NUMTDESC    ;yes start at begining    
  737.     mov    bx,XAREA
  738. tfl:
  739.     mov    [actsdesc],bx        ;set pointer
  740.  
  741.     mov    ax,0            
  742.     pop    ds
  743.     ret                ;good ret
  744.  
  745. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  746. ; xmt_errs:
  747. ;    Check at if the previous send has any errors or not.
  748. ;     entry - es:bx sdesc
  749. ;    exit  - ax:0 - ok; ffh:fatal error
  750. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  751.  
  752.     public    xmt_errs
  753. xmt_errs:
  754.     mov    ax,es:td_tdr[bx]    ;get rest of status
  755.     test    ax,t_more        ;more than one retry needed
  756.     jz    xisr2
  757.     call    count_out_err
  758.     jmp    xisr3
  759. xisr2:
  760.     test    ax,t_one        ;one retry?
  761.     jz    xisr3            ;no
  762.     call    count_out_err
  763. xisr3:
  764.     test    ax,t_lcol        ;late collision
  765.     jz    xisr4            ;no
  766.     call    count_out_err
  767. xisr4:
  768.     test    ax,t_def        ;deferred xmit?
  769.     jz    xisr5
  770.     call    count_out_err
  771. xisr5:
  772.     test    ax,t_lcar        ;loss of carrier
  773.     jz    xisr6
  774.     call    count_out_err
  775. xisr6:
  776.     test    ax,t_uflo        ;silo underflow?
  777.     jz    xisr7    
  778.     jmp    fatal_err
  779. xisr7:    
  780.     test    ax,t_buff        ;buffer error no end
  781.     jz    all_rite        ;last sent all right
  782. fatal_err:
  783.     call    count_out_err
  784.     mov    ax,0ffh            ;fatal error
  785.     ret                ;
  786.  
  787. all_rite:
  788.     mov    ax,0
  789.     ret
  790.  
  791. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  792. ;get_address:
  793. ;    We get the interface address from our internal version UNITID. 
  794. ;    set_address() could change the value of UNITID.
  795. ;
  796. ;enter with es:di -> place to put the address, cx = size of address buffer.
  797. ;exit with nc, cx = actual size of address, or cy if buffer not big enough.
  798. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  799.  
  800.     public    get_address
  801. get_address:
  802.     assume    ds:code
  803.     cmp    cx,EADDR_LEN        ;make sure that we have enough room.
  804.     jb    get_address_2
  805.     mov    cx,EADDR_LEN
  806.     lea    si,UNITID
  807. get_address_1:
  808.     call    movemem
  809.     mov    cx,EADDR_LEN
  810.     clc
  811.     ret
  812. get_address_2:
  813.     stc
  814.     ret
  815.     
  816. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  817. ; set_address:
  818. ;    set current ethernet address in UNITID, also change the init block
  819. ;       
  820. ;enter with ds:si -> Ethernet address, CX = length of address.
  821. ;exit with nc if okay, or cy, dh=error if any errors.
  822. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  823.  
  824.     public    set_address
  825. set_address:
  826.     assume    ds:nothing
  827.     push     ax
  828.     push    di
  829.     push    es
  830.     mov    ax,cs
  831.     mov    es,ax
  832.     
  833.     cmp    cx,EADDR_LEN
  834.     jne    set_address2
  835.  
  836.     push    si                ;save it for later use
  837.     push    cx
  838.  
  839.     mov    di,offset UNITID
  840.     call    movemem
  841.  
  842.     ;should also change the init_block
  843.     call    set_dp
  844.     mov    di,offset i_padr            
  845.     pop    cx
  846.     pop    si                ;get back the old pointer
  847.     call    movemem
  848.  
  849.     pop    es
  850.     pop    di
  851.     pop    ax
  852.     clc
  853.     ret
  854.  
  855. set_address2:
  856.     mov    dh,BAD_ADDRESS
  857.     stc
  858.     pop    es
  859.     pop    di
  860.     pop    ax
  861.     ret
  862.  
  863.  
  864.  
  865. rcv_mode_3:
  866. ;receive mode 3 is the only one we support, so we don't have to do anything.
  867.     ret
  868.  
  869.  
  870.     public    set_multicast_list
  871. set_multicast_list:
  872. ;enter with ds:si ->list of multicast addresses, cx = number of addresses.
  873. ;return nc if we set all of them, or cy,dh=error if we didn't.
  874.     mov    dh,NO_MULTICAST
  875.     stc
  876.     ret
  877.  
  878.  
  879.     public    terminate
  880. terminate:
  881.     ret
  882.  
  883.     public    reset_interface
  884. reset_interface:
  885. ;reset the interface.
  886.     assume    ds:code
  887.     call    hardware        ;reset the UNITID
  888.     cmp    al,0
  889.     jne    port_err
  890.  
  891.     cli
  892.  
  893.     call    lance_init        ;init_blk, xmt, rcv
  894.     cmp    ax,0            ;init ok?
  895.     jne    lance_err
  896.     sti
  897.     clc
  898.     ret
  899.  
  900. lance_err:
  901.     mov    dx,offset initerr_msg
  902.     ccall    _dispMSG,dx
  903.     jmp    error
  904.  
  905. port_err:    
  906.     mov    dx,offset reset_msg
  907.     ccall    _dispMSG,dx
  908. error:
  909.     mov    dh,CANT_RESET
  910.     stc
  911.     ret
  912.  
  913. ;called when we want to determine what to do with a received packet.
  914. ;enter with cx = packet length, es:di -> packet type.
  915.     extrn    recv_find: near
  916.  
  917. ;called after we have copied the packet into the buffer.
  918. ;enter with ds:si ->the packet, cx = length of the packet.
  919.     extrn    recv_copy: near
  920.  
  921.     extrn    count_in_err: near
  922.     extrn    count_out_err: near
  923.  
  924. ;called from the net_isr isr.  All registers have been saved, and ds=cs.
  925. ;Upon exit, the interrupt will be acknowledged.
  926. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  927. ; risr 
  928. ; receive interrupt service routine 
  929. ; exit: es,bx not changed
  930. ; registers: si,ax
  931. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  932.  
  933.     public    risr
  934. risr    proc    near
  935.     assume    ds:code
  936.     save    <es,bx>
  937.     call    set_dp            ;set es to dual port
  938. begin:
  939.     mov    si,[actrdesc]        ;active receive descriptor
  940.     mov    ax,es:rd_stat[si]    ;get descriptor status
  941.     test    ax,r_own        ;do we own it?
  942.     jnz    risr_done        ;this one is not filled
  943.  
  944.     call    dp_rcv            ;lance chip has rev'd a new packet
  945.                     ;reserve si 
  946.     ;One rint might indicate multiple recv's, check at the next one
  947.     add    si,SIZE rec_desc_ring        ;point at next descriptor
  948.     cmp    si,OUTOF_BOUND            ;RAREA+(numrxbuf-1)*(SIZE rec_desc_ring) = XAREA
  949.     jl    within
  950.     mov    si,RAREA
  951. within:
  952.     mov    [actrdesc],si            ;set active pointer
  953.     jmp    begin
  954. risr_done:
  955.     restore <bx,es>
  956.     ret
  957. risr    endp
  958.  
  959. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  960. ;  dp_rcv:
  961. ;    lance chip has one buffer filled, process it.
  962. ;    enter: es:si = actrdesc
  963. ;    exit:  actrdesc updated to next desc, si unchanged
  964. ;    registers: di,ax,bx
  965. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  966.  
  967.     public    dp_rcv
  968. dp_rcv     proc     near
  969.     push    si                ;save the old actdesc
  970.     push    es            ;gonna be changed in recv_find()
  971.  
  972.     mov    ax,es:rd_stat[si]    ;is it errored packet?
  973.     test    ax,r_err        ;
  974.     jz    noerr                 ;no err
  975.     call     rcverror        ;handle the err 
  976.     jmp    clrup
  977.  
  978. noerr:
  979.     mov     di,es:rd_addr[si]    ;received packet pointer es:di
  980.     add    di,EADDR_LEN + EADDR_LEN;stript off the two ether addresses
  981.                     ; & get to the packet type field
  982.     mov    cx,es:rd_mcnt[si]    ;everything (icl'g addresses)
  983.     and    cx,mcnt_mask        ;mask out the reserved bits
  984.  
  985.     push    ds            ;entry value saved
  986.  
  987.     push    es            ;es:di --> rcv'd data (icl'ing type)
  988.     push    di
  989.  
  990.     call    recv_find        ;ask for buffer from application es:di
  991.     mov    ax,es            ;is this pointer null?
  992.     or    ax,di
  993.     jz    too_bad            ;yes - just free the frame.
  994.     pop    si            ;put rcv'd data in ds:si, di->si
  995.     sub    si,EADDR_LEN + EADDR_LEN;we hand everything to the client
  996.     pop    ds            ;es->ds
  997.  
  998.     push    cx
  999.     push    es            ;for recv_copy(), es:di is user buf
  1000.     push    di            
  1001.  
  1002.     call    movemem            ;do the copy (including ether header)
  1003.  
  1004.     pop    si            ;di->si, es->ds
  1005.     pop    ds            ;ds:si --> user buffer now
  1006.     pop    cx            ;get back the length
  1007.     call    recv_copy
  1008.  
  1009.     pop    ds            ;original ds restored
  1010.     jmp    clrup
  1011.  
  1012. too_bad:
  1013.     pop    di
  1014.     pop    es
  1015.     pop    ds
  1016. clrup:
  1017.     ;either a bad or a good packet, we're done with it now
  1018.     pop    es            ;good old dp seg
  1019.     pop    si
  1020.     mov    es:rd_stat[si],r_own    ;desc reusable now
  1021.     ret
  1022. dp_rcv    endp
  1023.  
  1024. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1025. ; eisr
  1026. ; for lance error service routine
  1027. ;
  1028. ; entry - bx has status
  1029. ; exit  - bx unchanged, ax,cx changed
  1030. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1031.  
  1032.     public    eisr
  1033. eisr    proc    near
  1034.     test    bx,l_babl        ;transmission timeout?
  1035.     jz    eisr1            ;no
  1036.     call    count_out_err
  1037. eisr1:
  1038.     test    bx,l_cerr    
  1039.     jz    eisr2            ;no
  1040.     call    count_out_err
  1041. eisr2:
  1042.     test    bx,l_miss        ;missed packet?
  1043.     jz    eisr3
  1044.     call    count_out_err
  1045. eisr3:
  1046.     test    bx,l_merr        ;bus timeout?
  1047.     jz    eisr4            ;no
  1048.     call    count_out_err        ;this is a fatal error
  1049. eisr4:
  1050.     ret
  1051. eisr    endp
  1052.  
  1053.     include    movemem.asm
  1054.  
  1055. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1056. ; rcverror:
  1057. ;    entry    ax has rd_stat
  1058. ;
  1059. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1060.  
  1061.     public    rcverror
  1062. rcverror    proc    near
  1063.  
  1064.     test    ax,r_fram        ;framing error?
  1065.     jz    rerr0
  1066.     call     count_in_err
  1067. rerr0:
  1068.     test    ax,r_crc        ;crc error?
  1069.     jz    rerr1
  1070.     call     count_in_err
  1071. rerr1:
  1072.     test    ax,r_oflo          ;silo overflow?
  1073.     jz    rerr2
  1074.     call     count_in_err
  1075. rerr2:
  1076.     test    ax,r_buff        ;buffer error?
  1077.     jz    rerr3
  1078.     call     count_in_err
  1079. rerr3:
  1080.     ret
  1081. rcverror    endp
  1082.  
  1083. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1084. ; init_csr:
  1085. ;
  1086. ; initialize lance registers csr1, csr2, csr3
  1087. ;  entry - csr0 stop bit must have been set
  1088. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1089.  
  1090.     public    init_csr
  1091. init_csr    proc    near
  1092.     mov    al,csr1            ;set rap to csr1
  1093.     call    set_rap
  1094.     mov    ax,i_mode        ;init block starts at 0
  1095.     call    w_csr
  1096.  
  1097.     mov    al,csr2            ;set rap to csr2
  1098.     call    set_rap
  1099.     mov    ax,0            ;init block upper 8 bits are 0
  1100.     call    w_csr
  1101.  
  1102.     mov    al,csr3            ;set rap for csr3
  1103.     call    set_rap
  1104.     mov    ax,bus_master        ;bswp,acon,bcon
  1105.     call    w_csr
  1106.  
  1107.     mov    al,csr0            ;leave rap at csr0
  1108.     call    set_rap
  1109.     ret
  1110. init_csr    endp    
  1111.  
  1112. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1113. ; r_csr:
  1114. ;
  1115. ; read lance csr already selected into ax
  1116. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1117.  
  1118.     public    r_csr
  1119. r_csr    proc    near
  1120.     push    dx
  1121.     mov    dx,io_addr        ;now data port
  1122.     add    dx,pt_ldata
  1123.     in    ax,dx
  1124.     pop    dx
  1125.     ret
  1126. r_csr    endp
  1127. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1128. ; r_csr0
  1129. ;
  1130. ; read lance csr0
  1131. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1132.  
  1133.     public    r_csr0
  1134. r_csr0    proc    near
  1135.     push    dx
  1136.     mov    al,csr0            ;set rap to csr1
  1137.     call    set_rap
  1138.     mov    dx,io_addr        ;now data port
  1139.     add    dx,pt_ldata
  1140.     in    ax,dx
  1141.     pop    dx
  1142.     ret
  1143. r_csr0    endp
  1144.  
  1145. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1146. ; set_initblk:  
  1147. ;
  1148. ; set up lance initialization block in the dual port  
  1149. ;
  1150. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;                       ;
  1151.  
  1152.     public    set_initblk,si11
  1153. set_initblk  proc    near
  1154.     push    es
  1155.     call    set_dp            ;get lance data seg
  1156.  
  1157.     mov    ax,run_mode        ;mode
  1158.     mov    es:[i_mode],ax        ;(es = dpseg);1st word in the dp
  1159.     lea    si,UNITID        ;set in physical address
  1160.     mov    di,i_padr        ; from the board
  1161. si11:
  1162.     mov    cx,6
  1163.     rep    movsb
  1164. ;
  1165. ;forget about the logical address filter for now --mz??
  1166. ;
  1167.     mov    ax,RAREA        ;set in pointer to 1ST receive desc.
  1168.     mov    es:[i_rdra],ax        ;set lo addr (0-15)
  1169.     mov    ah,rlen            ;set in rlen parameter & hi addr (00s)
  1170.     mov    al,0
  1171.     mov    es:[i_rlen],ax        ;4 rcv descriptors
  1172.     mov    ax,XAREA        ;pointer to xmit descriptors
  1173.     mov    es:[i_tdra],ax
  1174.     mov    ah,tlen            ;set in tlen parameter 1 = 2
  1175.     mov    al,0
  1176.     mov     es:[i_tlen],ax
  1177.     pop    es
  1178.     ret
  1179. set_initblk    endp
  1180.  
  1181. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1182. ; set_dp
  1183. ;    es<-- cs:base_address
  1184. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1185.  
  1186.     public    set_dp
  1187. set_dp:
  1188.     assume    cs:code
  1189.     push    ax
  1190.     mov    ax,cs:[base_addr]
  1191.     mov    es,ax
  1192.     pop    ax
  1193.     ret
  1194.  
  1195. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1196. ; set_ds:
  1197. ;     ds<--cs
  1198. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1199. set_ds:
  1200.     push    ax
  1201.     mov    ax,cs
  1202.     mov    ds,ax
  1203.     pop    ax
  1204.     ret
  1205.  
  1206. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1207. ; set up transmit message descriptors
  1208. ;
  1209. ; entry - cx has number of descriptors and buffers to set up
  1210. ;         bx has pointer of start of descriptors
  1211. ;         di has pointer to start of buffer area
  1212. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1213.  
  1214.     public    su_tmd
  1215. su_tmd    proc    near
  1216.     push    es
  1217.     call    set_dp            ;get lance data seg
  1218.  
  1219.     ;first set the relative parameters
  1220.     mov    [sdesc_cnt],cx        ;set in count
  1221.     mov    [actsdesc],bx
  1222.  
  1223. su_t0:
  1224.     mov    es:td_addr[bx],di    ;set in pointer
  1225.     mov    ax,BUFSIZE        ;total size
  1226.     neg    ax            ;two's compliment
  1227.     or    ax,td_bmask        ;set these bits
  1228.     mov    es:td_bcnt[bx],ax    ;set in length to descriptor
  1229.     mov    ax,0            ;set descriptor status for lance
  1230.     or    ax,t_stp        ;start of packet
  1231.     or    ax,t_enp        ;end of packet
  1232.     mov    es:td_stat[bx],ax    ;give it away        
  1233.     mov    es:td_tdr[bx],0
  1234.     add    bx,tdesclen        ;point at next descriptor
  1235.     add    di,BUFSIZE        ;and next buffer
  1236.     loop    su_t0            ;do all
  1237.     pop    es
  1238.     ret
  1239. su_tmd    endp
  1240.  
  1241. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1242. ; set up receive message descriptors
  1243. ;
  1244. ; entry - cx has number of descriptors and buffers to set up
  1245. ;         bx has pointer of start of descriptors
  1246. ;         di has pointer to start of buffer area
  1247. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1248.  
  1249.     public    su_rmd
  1250. su_rmd    proc    near
  1251.     push    es
  1252.     call    set_dp    ;get lance data seg
  1253.  
  1254.     mov    [actrdesc],bx          ;pointer to active descriptor
  1255.     mov    [rdesc_cnt],cx        ;descriptor count
  1256. su_r0:
  1257.     mov    es:rd_addr[bx],di       ;set in pointer to pointer
  1258.     mov    ax,r_own        ;set up descriptor status 
  1259.     mov    es:rd_stat[bx],ax
  1260.     xor    ax,ax            ;zero out count
  1261.     mov    es:rd_mcnt[bx],ax
  1262.     mov    ax,BUFSIZE        ;set in length of buffer
  1263.     neg    ax            ;must be two's compliment
  1264.     or    ax,rd_mask        ;need these bits set
  1265.     mov    es:rd_bcnt[bx],ax
  1266.     add    bx,rdesclen        ;point at next descriptor
  1267.     add    di,BUFSIZE        ;and next buffer
  1268.     loop    su_r0            ;do all
  1269.     
  1270.     pop    es
  1271.     ret
  1272. su_rmd    endp
  1273.  
  1274. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1275. ; lance_reset:
  1276. ;
  1277. ;     reset lance chip; select csr0 and set the stop bit
  1278. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;        
  1279.  
  1280.     public    lance_reset
  1281. lance_reset    proc    near
  1282.     mov    dx,io_addr        ;pop the reset line
  1283.     add    dx,pt_resetl    
  1284.     out    dx,al
  1285.     mov    al,csr0            ;set lance address port to csr0
  1286.     call    set_rap
  1287.     mov    ax,l_stop         ;and set stop bit
  1288.     call    w_csr
  1289.     ret
  1290. lance_reset    endp
  1291.  
  1292. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1293. ; w_csr:
  1294. ;
  1295. ; output ax to lance csr already selected
  1296. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1297.  
  1298.     public    w_csr
  1299. w_csr    proc    near
  1300.     push    dx
  1301.     mov    dx,io_addr        ;now data port
  1302.     add    dx,pt_ldata
  1303.     out    dx,ax
  1304.     pop    dx
  1305.     ret    
  1306. w_csr    endp
  1307.  
  1308. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1309. ; set_rap:
  1310. ;
  1311. ; set lance address port to register in al
  1312. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1313.  
  1314.     public    set_rap
  1315. set_rap    proc    near
  1316.     push    dx
  1317.     mov    dx,io_addr        ;get base address
  1318.     add    dx,pt_laddr                ;point at lance address port
  1319.     xor    ah,ah            ;point at csr
  1320.     out    dx,ax
  1321.     pop    dx
  1322.     ret
  1323. set_rap        endp
  1324.  
  1325. ; hardwre() and lance_init() are TSR just for the 
  1326. ; support of reset_interface();
  1327.  
  1328. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1329. ; hardware: 
  1330. ;    verify the port #;
  1331. ;    set ethernet addr in _UNITID
  1332. ;
  1333. ; exit:
  1334. ;    [_UNITID] = board ethernet address
  1335. ;       al = 0 (ok)
  1336. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1337.  
  1338.     public    hardware
  1339. hardware    proc    near
  1340.     ;verify the port #
  1341.     mov    dx,io_addr
  1342.     call    chkaddr
  1343.     cmp    al,0            ;ok?
  1344.     jz    hw1            ;yes, use #1
  1345.     mov    ax,offset porterr_msg
  1346.     ccall    _dispMSG,ax
  1347.     jmp    hw_error
  1348.  
  1349. hw1:
  1350.     ;ok, now zero the ram out so that we can use it
  1351.     call    set_dp
  1352.     call     zeroram
  1353.  
  1354.     ;get ether address
  1355.     mov    cx,6            ;get the ethernet address
  1356.     add    dx,pt_etaddr
  1357.     mov    bx,offset UNITID    ;to here
  1358. hw3:
  1359.     in    al,dx
  1360.     mov    byte ptr[bx],al
  1361.     inc    bx
  1362.     loop    hw3
  1363.  
  1364.     ;validate int_no (only support 10,11,12,15)
  1365.     
  1366.     mov    bl,IRQ10        ;assume it's irq10
  1367.     mov    dx,io_addr        ;port base
  1368.     add     dx,pt_status        ;status port
  1369.     in    al,dx            ;get status
  1370.     and    al,st_mask        ;get the 2 bits
  1371.     cmp    al,irqn_10        ;(IS0 IS1)=(0 0) selects irq10
  1372.     je    alset
  1373.     inc    bl            ;try irq11
  1374.     cmp    al,irqn_11
  1375.     je    alset
  1376.     inc    bl            ;try irq12
  1377.     cmp    al,irqn_12
  1378.     je    alset
  1379.     mov    bl,15            ;try irq15
  1380.     cmp    al,irqn_15
  1381.     jne    hw_error
  1382.  
  1383. alset:
  1384.     ;did we get the right int_no in bl?
  1385.     cmp    bl,int_no
  1386.         jmp     ok                      ; #### temp patch, BKC
  1387. ;    je    ok
  1388.     ;otherwise, error
  1389.     mov    ax,offset interr_msg
  1390.     ccall    _dispMSG,ax
  1391. hw_error:
  1392.     mov    al,0ffh
  1393.     ret
  1394. ok:
  1395.     mov    al,0            ;good return code
  1396.     ret
  1397. hardware    endp
  1398.  
  1399. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1400. ; chkaddr: check if we are using the right i/o port
  1401. ;          this is done by reading the port status and comparing
  1402. ;       with cs - 800h
  1403. ;
  1404. ; entry:     io_addr == i/o port #
  1405. ; exit:     ah -- dual port segment
  1406. ;        al -- 00h (succ) or ffh (error)
  1407. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1408.  
  1409.     public    chkaddr
  1410. chkaddr    proc    near
  1411.     push    dx
  1412.  
  1413.     mov    dx,io_addr
  1414.     in    al,dx            ;read in status byte
  1415.     and    al,addr            ;get dp seg, addr = 0f0h
  1416.     mov    ah,al            ;save
  1417.  
  1418.     mov    dx,base_addr
  1419.     and    dh,addr
  1420.     cmp    al,dh
  1421.     je    chk2
  1422.     mov    al,0ffh            ;error
  1423.     pop    dx
  1424.     ret
  1425. chk2:
  1426.     mov    al,0            ;ok
  1427.     pop    dx
  1428.     ret
  1429. chkaddr    endp
  1430.  
  1431. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1432. ; zeroram - zero dual port ram
  1433. ;    seg in [dpseg]
  1434. ;    registers: di,cx,al
  1435. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1436.  
  1437.     public    zeroram
  1438. zeroram    proc    near
  1439.     cld                ;auto increment
  1440. zram1:    
  1441.     mov    di,0            ;start at 0;dpseg:di
  1442.     mov    cx,dplen        ;dual port length
  1443.     mov    al,0            ;data to go
  1444.     rep    stosb            ;zero em all
  1445.     ret
  1446. zeroram    endp
  1447.  
  1448. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1449. ; lance_init:
  1450. ;
  1451. ; init lance chip; first setup init_blk, r & s descriptors in dp
  1452. ;           then set the chip to go.
  1453. ;    exit: ax = 1: error; 0 OK. 
  1454. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1455.  
  1456.     public    lance_init, il0, il1
  1457. lance_init    proc    near
  1458.     call    set_initblk        ;set up lance initialization block
  1459.  
  1460.     ;set up transmit descriptors & buffers
  1461.     mov    cx,NUMTDESC        ;get no. of transmit blocks to build
  1462.     mov    bx,XAREA        ;point at descriptor memory pool
  1463.     mov    di,TBAREA        ;and buffer pool
  1464.     call    su_tmd            ;set up transmit descriptors
  1465.  
  1466.     ;set up receive descriptors & buffers
  1467.     mov    cx,NUMRDESC        ;set up receive descriptors
  1468.     mov    bx,RAREA        ;descriptor area
  1469.     mov    di,RBAREA        ;buffer area
  1470.     call    su_rmd            ;set up receive descriptors
  1471.  
  1472.     call    lance_reset        ;ensure reset
  1473.     call    init_csr        ;initialize lance registers
  1474.                     ;also set rap to csr0 with stop set
  1475.     ;now start the lance initialization action
  1476.     CLI
  1477.     mov    ax,l_init+l_strt    ;write init & start to csr0
  1478.     call    w_csr
  1479.  
  1480.     ;rap = csr0 now, let's check at csr0
  1481.        mov    cx,0
  1482.     dec    cx
  1483. il0:
  1484.     call    r_csr            ;get lance status register
  1485.     test    ax,l_idon        ;init done set?
  1486.     jnz    il1
  1487.     loop    il0
  1488.     ;sth wrong with the chip, can't init
  1489.     mov    ax,offset chperr_msg
  1490.     ccall    _dispMSG,ax
  1491.     mov    ax,1            ;error return
  1492.     ret
  1493. il1:
  1494.     mov    ax,l_idon+l_inea    ;this drives /intr pin to low
  1495.     call    w_csr            ;enable network ints
  1496.     STI
  1497.     mov    ax,0            ;good return
  1498.     ret
  1499. lance_init    endp
  1500.  
  1501. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1502. ;  tickscreen
  1503. ;
  1504. ;  For debug this routine can be called to tick over the screen at the 
  1505. ;  specified location.
  1506. ;
  1507. ;    c callable:    tickscreen(loc);
  1508. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1509.  
  1510.     public    _tickscreen
  1511. _tickscreen    proc near
  1512.     push    bp
  1513.     mov    bp,sp
  1514.     save    <ax,bx,ds>
  1515.     mov    bx,04[bp]        ;get screen position
  1516.     add    bx,bx            ;*2
  1517. IFDEF COLOR
  1518.     mov    ax,0b800h
  1519. ELSE
  1520.     mov    ax,0b000h
  1521. ENDIF
  1522.     mov    ds,ax
  1523.     inc    byte ptr [bx]            ;tick it
  1524.     restore    <ds,bx,ax>
  1525.     pop    bp
  1526.     ret
  1527. _tickscreen    endp
  1528.  
  1529. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1530. ; _dispMSG:
  1531. ;    c call: dispMSG(&msg);
  1532. ;    put the '$' terminated message to screen
  1533. ;    entry: dx - point to the message
  1534. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1535.  
  1536.     public    _dispMSG
  1537. _dispMSG proc near
  1538.     push    bp
  1539.     mov    bp,sp
  1540.     push    dx
  1541.     mov    dx,4[bp]
  1542.  
  1543.     push    ax
  1544.     mov    ah,9
  1545.     int    21h
  1546.     pop    ax
  1547.  
  1548.     pop    dx
  1549.     pop    bp
  1550.     ret
  1551. _dispMSG endp
  1552.  
  1553.  
  1554.     public    recv
  1555. recv:
  1556. ;called from the recv isr.  All registers have been saved, and ds=cs.
  1557. ;Upon exit, the interrupt will be acknowledged.
  1558.     assume    ds:code
  1559.  
  1560. recv_0:
  1561.     mov    dx,io_addr        ;get the iobase
  1562.     add    dx,pt_status        ;the read status port
  1563.     in    al,dx            ;get board status
  1564.  
  1565.     test    al,clk_int        ;look for clock interrupt
  1566.     jz    ni10            ;no clock int
  1567.     mov    dx,base_addr
  1568.     add    dx,pt_clrclk        ;reset the ckock
  1569.     out     dx,al
  1570. ni10:
  1571.     test    al,net_int        ;network int bit cleared?
  1572.     jnz    nisr5            ;look for 0 here, set means none
  1573.  
  1574.     call    r_csr            ;get lance status register -- in ax
  1575.     mov    bx,ax
  1576.     and    ax,l_mask         ;clear out ints and mask any more
  1577.     call    w_csr
  1578.  
  1579.     test    bx,l_err        ;check for errors first
  1580.     jz    nisr2            ;no error
  1581.     call    eisr
  1582. nisr2:
  1583.     test    bx,l_rint        ;test for receive active
  1584.     jz    nisr6            ;no r_int
  1585.     call    risr
  1586. nisr6:
  1587.     mov     ax,l_inea        ;re-enable the int
  1588.     call    w_csr
  1589.     jmp    recv_0            ;check again for ints
  1590. nisr5:
  1591.     ret
  1592.  
  1593.  
  1594.     public    recv_exiting
  1595. recv_exiting:
  1596. ;called from the recv isr after interrupts have been acknowledged.
  1597. ;Only ds and ax have been saved.
  1598.     assume    ds:nothing
  1599.     ret
  1600.  
  1601.  
  1602. ;any code after this will not be kept after initialization.
  1603. end_resident    label    byte
  1604.  
  1605.  
  1606.     public    usage_msg
  1607. usage_msg    db    "usage: nti16 [-n] [-d] [-w] <packet_int_no> <irq_no> <port_no> <base_addr>",CR,LF,'$'
  1608.  
  1609.     public    copyright_msg
  1610. copyright_msg    db    "Packet driver for nti network device, version ",'0'+version,CR,LF,'$'
  1611.         db    "Copyright 1990, Michael Zheng",CR,LF,'$'
  1612.  
  1613.  
  1614. ;enter with si -> argument string, di -> wword to store.
  1615. ;if there is no number, don't change the number.
  1616.     extrn    get_number: near
  1617.  
  1618. ;enter with dx -> name of word, di -> dword to print.
  1619.     extrn    print_number: near
  1620.  
  1621.     public    parse_args
  1622. parse_args:
  1623.     mov    di,offset int_no
  1624.     mov    bx,offset int_no_name
  1625.     call    get_number
  1626.     mov    di,offset io_addr
  1627.     mov    bx,offset io_addr_name
  1628.     call    get_number
  1629.     mov    di,offset base_addr
  1630.     mov    bx,offset base_addr_name
  1631.     call    get_number
  1632.     ret
  1633.  
  1634. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1635. ; etopen:
  1636. ;    initialize the interface in order to function
  1637. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1638.  
  1639.     public    etopen
  1640. etopen:
  1641.  
  1642.  
  1643.     public    beginbios
  1644. beginbios:
  1645.  
  1646.     call     hardware        ;decide port #; _UNITID; zeroram
  1647.                     ;and 16-bit board specific:
  1648.                     ;decide the int_no validity --mz!!
  1649.     cmp    al,0
  1650.     jz    beg0            ;ok
  1651.     mov    ax,offset hwerr_msg    ;error return
  1652.     ccall    _dispMSG,ax
  1653.     mov    ax, 4c00H
  1654.     int    21h            ;terminate it
  1655. beg0:
  1656.  
  1657.     mov    al,int_no
  1658.     call    maskint
  1659.     call    lance_init        ;init the lance chip
  1660.     cmp    ax,1            ;init error?
  1661.     jne    good            ;ok
  1662.  
  1663.     mov    ax,offset initerr_msg    ;can't init message
  1664.     ccall    _dispMSG,ax
  1665.     stc    
  1666.     ret
  1667.  
  1668. good:
  1669.     call    set_recv_isr
  1670.  
  1671.     mov    al, int_no        ; Get board's interrupt vector
  1672.     add    al, 8
  1673.     cmp    al, 8+8            ; Is it a slave 8259 interrupt?
  1674.     jb    set_int_num        ; No.
  1675.     add    al, 70h - 8 - 8        ; Map it to the real interrupt.
  1676. set_int_num:
  1677.     xor    ah, ah            ; Clear high byte
  1678.     mov    int_num, ax        ; Set parameter_list int num.
  1679.  
  1680.     mov    ax,offset good_msg
  1681.     ccall    _dispMSG,ax
  1682.  
  1683.     mov    dx,offset end_resident    ;in paragraphs
  1684.     clc
  1685.     ret
  1686.  
  1687.     public    print_parameters
  1688. print_parameters:
  1689. ;echo our command-line parameters
  1690.     mov    di,offset int_no
  1691.     mov    bx,offset int_no_name
  1692.     call    get_number
  1693.     mov    di,offset io_addr
  1694.     mov    bx,offset io_addr_name
  1695.     call    get_number
  1696.     mov    di,offset base_addr
  1697.     mov    bx,offset base_addr_name
  1698.     call    get_number
  1699.     ret
  1700.  
  1701. code    ends
  1702.  
  1703.     end
  1704.